package org.thread.test03.way03;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author CSY
 * @date 2025 - 03 - 10
 */
public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 第二：工具类Executors创建线程池并返回ExecutorService对象
        ExecutorService executorService = Executors.newFixedThreadPool(10) ;
        // 第三：创建Future对象
        //executorService.submit(Callable对象|Runnable对象);
        Future<String> future = executorService.submit(new MyCallable());
        //第四：获取值
        String msg = future.get();

        System.out.println(msg);

        System.out.println("主线程的一些处理...");

        //第五：停止服务`
        executorService.shutdownNow();

    }
}
